/*
 * Copyright 2008 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.dopdf.document.request;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * The interface that represents a given request processor.  The implementing classes should tell
 * whether they can process the specified request or not.  If given a chance they should also process the request.
 *
 * @author Deep Shah
 */
public interface RequestProcessor {

    /**
     * The method that should return true or false based on the fact whether they can process the request or not.
     *
     * @param request the request that is to be processed.
     * @return true if class can process the request, false otherwise.
     */
    boolean canProcess(final HttpServletRequest request);

    /**
     * This method will be called only if canProcess has returned true for a given request.
     *
     * @param request  the request to process.
     * @param response the response object, used to write response.
     */
    void process(final HttpServletRequest request, final HttpServletResponse response);
}
